import { isValidPhone } from '@/utils/rules';

export const rules = {
  phoneNumber: {
    required: true,
    validator: (rule: any, value: any) => {
      if (isValidPhone(value)) {
        return Promise.resolve();
      }
      return Promise.reject(`请输入手机号`);
    },
  },

  imageCode: [
    { required: true, message: '请输入验证码', trigger: 'change' },
    { min: 3, max: 4, message: '长度为4个字符', trigger: 'change' },
  ],
  phoneCode: [
    { required: true, message: '请输入短信验证码', trigger: 'change' },
    { min: 4, max: 4, message: '长度为4个字符', trigger: 'change' },
  ],
};
